<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The Swoole\Client class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="swoole-channel.stats.html">« Swoole\Channel::stats</a></li>
      <li style="float: right;"><a href="swoole-client.close.html">Swoole\Client::close »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.swoole.html">Swoole</a></li>
    <li>The Swoole\Client class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.swoole-client" class="reference">

 <h1 class="title">The Swoole\Client class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL swoole &gt;= 1.9.0)</p>


  <div class="section" id="swoole-client.intro">
   <h2 class="title">简介</h2>
   <p class="para">

   </p>
  </div>


  <div class="section" id="swoole-client.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">Swoole\Client</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.swoole-client.html#swoole-client.constants.msg-oob"><var class="varname">MSG_OOB</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.swoole-client.html#swoole-client.constants.msg-peek"><var class="varname">MSG_PEEK</var></a></var><span class="initializer"> = 2</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.swoole-client.html#swoole-client.constants.msg-dontwait"><var class="varname">MSG_DONTWAIT</var></a></var><span class="initializer"> = 128</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.swoole-client.html#swoole-client.constants.msg-waitall"><var class="varname">MSG_WAITALL</var></a></var><span class="initializer"> = 64</span>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.swoole-client.html#swoole-client.props.errcode">$<var class="varname">errCode</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.swoole-client.html#swoole-client.props.sock">$<var class="varname">sock</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.swoole-client.html#swoole-client.props.reuse">$<var class="varname">reuse</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.swoole-client.html#swoole-client.props.reusecount">$<var class="varname">reuseCount</var></a></var>;</div>


    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="swoole-client.close.html" class="methodname">close</a></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$force</code><span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.connect.html" class="methodname">connect</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$timeout</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$flag</code><span class="initializer"> = ?</span></span><br>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.destruct.html" class="methodname">__destruct</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.getpeername.html" class="methodname">getpeername</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.getsockname.html" class="methodname">getsockname</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.isconnected.html" class="methodname">isConnected</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.on.html" class="methodname">on</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$event</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.pause.html" class="methodname">pause</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.pipe.html" class="methodname">pipe</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$socket</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.recv.html" class="methodname">recv</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$size</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$flag</code><span class="initializer"> = ?</span></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.resume.html" class="methodname">resume</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.send.html" class="methodname">send</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$flag</code><span class="initializer"> = ?</span></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.sendfile.html" class="methodname">sendfile</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code><span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.sendto.html" class="methodname">sendto</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$ip</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.set.html" class="methodname">set</a></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$settings</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.sleep.html" class="methodname">sleep</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="swoole-client.wakeup.html" class="methodname">wakeup</a></span>(): <span class="type"><span class="type void">void</span></span></div>

   }</div>


  </div>

  

  <div class="section" id="swoole-client.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="swoole-client.props.errcode"><var class="varname">errCode</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="swoole-client.props.sock"><var class="varname">sock</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="swoole-client.props.reuse"><var class="varname">reuse</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="swoole-client.props.reusecount"><var class="varname">reuseCount</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
   </dl>

  </div>


  

  <div class="section" id="swoole-client.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="swoole-client.constants.msg-oob"><strong><code>Swoole\Client::MSG_OOB</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="swoole-client.constants.msg-peek"><strong><code>Swoole\Client::MSG_PEEK</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="swoole-client.constants.msg-dontwait"><strong><code>Swoole\Client::MSG_DONTWAIT</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

    
     <dt id="swoole-client.constants.msg-waitall"><strong><code>Swoole\Client::MSG_WAITALL</code></strong></dt>

     <dd>

      <p class="para"/>
     </dd>

    

   </dl>

  </div>



 </div>

 































































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="swoole-client.close.html">Swoole\Client::close</a> — Close the connection established.</li><li><a href="swoole-client.connect.html">Swoole\Client::connect</a> — Connect to the remote TCP or UDP port.</li><li><a href="swoole-client.construct.html">Swoole\Client::__construct</a> — Create Swoole sync or async TCP/UDP client, with or without SSL.</li><li><a href="swoole-client.destruct.html">Swoole\Client::__destruct</a> — Destruct the Swoole client.</li><li><a href="swoole-client.getpeername.html">Swoole\Client::getpeername</a> — Get the remote socket name of the connection.</li><li><a href="swoole-client.getsockname.html">Swoole\Client::getsockname</a> — Get the local socket name of the connection.</li><li><a href="swoole-client.isconnected.html">Swoole\Client::isConnected</a> — Check if the connection is established.</li><li><a href="swoole-client.on.html">Swoole\Client::on</a> — Add callback functions triggered by events.</li><li><a href="swoole-client.pause.html">Swoole\Client::pause</a> — Pause receiving data.</li><li><a href="swoole-client.pipe.html">Swoole\Client::pipe</a> — Redirect the data to another file descriptor.</li><li><a href="swoole-client.recv.html">Swoole\Client::recv</a> — Receive data from the remote socket.</li><li><a href="swoole-client.resume.html">Swoole\Client::resume</a> — Resume receiving data.</li><li><a href="swoole-client.send.html">Swoole\Client::send</a> — Send data to the remote TCP socket.</li><li><a href="swoole-client.sendfile.html">Swoole\Client::sendfile</a> — Send file to the remote TCP socket.</li><li><a href="swoole-client.sendto.html">Swoole\Client::sendto</a> — Send data to the remote UDP address.</li><li><a href="swoole-client.set.html">Swoole\Client::set</a> — Set the Swoole client parameters before the connection is established.</li><li><a href="swoole-client.sleep.html">Swoole\Client::sleep</a> — Remove the TCP client from system event loop.</li><li><a href="swoole-client.wakeup.html">Swoole\Client::wakeup</a> — Add the TCP client back into the system event loop.</li></ul>
</div>
</div></div></body></html>